package com.hzqy.web.ac.epg;


import com.hzqy.commons.utils.ExcelUtil;
import com.hzqy.commons.utils.ExcelUtil.MyEntry;
import com.hzqy.service.epg.AcRecordListService;
import com.hzqy.service.epg.AcRecordService;
import com.hzqy.web.vo.AcWinningVo;
import com.hzqy.web.vo.epg.AcRecordListVo;
import com.hzqy.web.vo.epg.AcRecordVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/acRecordList")
public class AcRecordListAction {
	protected final Logger LOG = LoggerFactory.getLogger(getClass());
    @Resource
	private AcRecordListService serviceAction;
    @RequestMapping("/acRecordListSelectAll")
	@ResponseBody
	public Object acRecordSelect(AcRecordListVo arv, int page, int rows){
		Map<String,Object> RecordListMap = new HashMap<String, Object>();
		RecordListMap= serviceAction.selectAc(arv,page, rows);
		return RecordListMap;
	}
	@RequestMapping("/acRecordListExcel")
	@ResponseBody
	public void acRecordExcel(AcRecordListVo infoVo, HttpSession session, int page, int rows, HttpServletResponse response) throws IOException {
		Map<String,Object> ListMap = new HashMap<String, Object>();
    	ListMap = serviceAction.selectAc(infoVo,1,100000);
		List<AcWinningVo> data=(List<AcWinningVo>)ListMap.get("rows");
		List<MyEntry<String, String>> excelHeader=new ArrayList<MyEntry<String, String>>();
		excelHeader.add(new MyEntry<String,String>("x_lwj_id","ID"));
		excelHeader.add(new MyEntry<String,String>("x_lwj_uesr_id","业务帐号"));
		excelHeader.add(new MyEntry<String,String>("x_lwj_phone","手机号"));
		excelHeader.add(new MyEntry<String,String>("x_lwj_activityid","活动名称"));
		excelHeader.add(new MyEntry<String,String>("x_lwj_by","戏曲答题结果"));
		boolean flag= ExcelUtil.generateExcel(data, excelHeader, response);
	}

}
